package com.ywh.bigevent.controller;

import com.ywh.bigevent.pojo.Result;
import com.ywh.bigevent.utils.JwtUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/article")
public class ArticleController {
    @GetMapping("/list")
    public Result<String> list(@RequestHeader(name="Authorization") String token, HttpServletResponse response)
    {
        //验证token
        //test push
        try {
            Map<String, Object> clamis = JwtUtil.parseToken(token);
            return Result.success("所有的文章数据。。。");
        }catch (Exception e){
            //Http响应状态码为401
            response.setStatus(401);
            return Result.error("未登录");
        }
    }
}
